#pragma once

typedef struct GRAPHIC
{
	HBITMAP		hBitmap;
	LONG		width;
	LONG		height;
	LONG		pitch;
	PVOID		pBits;
	RECT		rcBound;
	BITMAPINFO	bmInfo;
} GRAPHIC, *PGRAPHIC;

PGRAPHIC CreateGraphic( int width, int height, int colorDepth, const RGBQUAD* pColorTbl = NULL );
int SetColorTable( PGRAPHIC g, unsigned startIndex, unsigned entries, const RGBQUAD* pColors );

inline
void ClearGraphic( PGRAPHIC pGraphic )
{
	memset( pGraphic->pBits, 0, pGraphic->pitch * pGraphic->height );
}

inline
void DeleteGraphic( PGRAPHIC pGraphic )
{
	if ( pGraphic && pGraphic->hBitmap )
	{
		DeleteObject(pGraphic->hBitmap);
	}
	delete [] (char*)pGraphic;
}